package com.bwie.controller;

import com.bwie.pojo.TbProd;
import com.bwie.pojo.TbProdAtta;
import com.bwie.service.TbProdService;
import com.bwie.utils.R;
import com.bwie.vo.ProdPageVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author 军哥
 * @version 1.0
 * @description: TODO
 * @date 2025/6/24 9:58
 */

@RestController
@RequestMapping("/shop/prod")
public class ProdController {

    @Autowired
    TbProdService tbProdService;

    /**
     * @description 分页获取商品列表
     * @params []
     * @return com.bwie.utils.R
     * @author 军哥
     * @date 2025/6/24 9:58
     */
    @PostMapping("/getProdList")
    public R getProdList(@RequestBody ProdPageVo prodPageVo) {
        return tbProdService.getProdList(prodPageVo);
    }

    /**
     * @description 添加商品基本信息
     * @params [tbProd]
     * @return com.bwie.utils.R
     * @author 军哥
     * @date 2025/6/24 16:48
     */
    @PostMapping("/addProd")
    public R addProd(@RequestBody @Validated TbProd tbProd) {
        return tbProdService.addProd(tbProd);
    }

    /**
     * @description 添加商品附件
     * @params [tbProdAtta]
     * @return com.bwie.utils.R
     * @author 军哥
     * @date 2025/6/25 15:40
     */
    @PostMapping("/addProdAtta")
    public R addProdAtta(@RequestBody TbProdAtta tbProdAtta) {
        return tbProdService.addProdAtta(tbProdAtta);
    }

    /**
     * @description 批量删除商品信息
     * @params [ids]
     * @return com.bwie.utils.R
     * @author 军哥
     * @date 2025/6/26 13:48
     */
    @PostMapping("/deleteBatchProd")
    public R deleteBatchProd(@RequestBody List<Integer> ids) {
        return tbProdService.deleteBatchProd(ids);
    }

    /**
     * @description 根据商品ID删除商品
     * @params [prodId]
     * @return com.bwie.utils.R
     * @author 军哥
     * @date 2025/6/26 14:42
     */
    @PostMapping("/deleteProd/{prodId}")
    public R deleteProd(@PathVariable("prodId") Integer prodId) {
        return tbProdService.deleteProd(prodId);
    }

    /**
     * @description 商品信息列表
     * @params []
     * @return com.bwie.utils.R
     * @author 军哥
     * @date 2025/6/26 16:30
     */
    @PostMapping("/getProdInfoList")
    public R getProdInfoList() {
        return tbProdService.getProdInfoList();
    }

    /**
     * @description 从ES中分页获取商品列表
     * @params [prodPageVo]
     * @return com.bwie.utils.R
     * @author 军哥
     * @date 2025/6/30 15:31
     */
    @PostMapping("/getProdFromEs")
    public R getProdFromEs(@RequestBody ProdPageVo prodPageVo) {
        return tbProdService.getProdFromEs(prodPageVo);
    }

}
